package shanhai;

public class MultiCallbackExample {
    public static void main(String[] args) {
        feachData(
                data -> System.out.println("success:" + data),
                error -> System.out.println("error:" + error));
    }

    public static void feachData(SuccessCallback onSuccess, ErrorCallback onError) {
        if (Math.random() > 0.5)
            onSuccess.onSuccess("success...");
        else
            onError.onError("error...");
    }

    interface SuccessCallback {
        void onSuccess(String result);
    }

    interface ErrorCallback {
        void onError(String error);
    }
}
